package com.frikinet.tools.gui;

import java.awt.Component;
import java.awt.Point;

import javax.swing.JPopupMenu;
import javax.swing.MenuElement;

import com.frikinet.tools.i18n.FI18N;
import com.frikinet.tools.i18n.Translable;

public class FPopupMenu extends JPopupMenu implements Translable
{
	private static final long serialVersionUID = 1L;
	
	private FI18N i18n = null;
	private Object source = null;
	
	public FI18N getI18n()
	{
		return i18n;
	}

	public void setI18N(FI18N i18n)
	{
		this.i18n = i18n;
	}
	
	public Object getSource()
	{
		return source;
	}

	public void setSource(Object source)
	{
		this.source = source;
	}

	public void translate()
	{
		for(MenuElement e: getSubElements())
		{
			if(e instanceof Translable)
				((Translable)e).translate();
		}
	}
	
	public void showOn(Object source, Component invoker, Point p)
	{
		setSource(source);
		show(invoker,(int)p.getX(),(int)p.getY());
	}
}
